#!/usr/bin/env python
# -*- encoding: utf-8 -*-

from socket import *
from time import *

HOST = "localhost"
SERVER_PORT = 9999
CLIENT_PORT = 8888

clnt_sock = socket(AF_INET, SOCK_DGRAM)
clnt_sock.setsockopt(SOL_SOCKET, SO_REUSEADDR, 1)
clnt_sock.bind(('', CLIENT_PORT))

print "메시지 송신중..."
clnt_sock.sendto("Hello, EunSeok!!", (HOST, SERVER_PORT))
print "메시지 송신 완료"

print "메시지 수신 대기중..."
msg, addr = clnt_sock.recvfrom(1024)
print "메시지 수신 완료"
print msg, addr

print "5초간 sleep"
sleep(5)

print "메시지 송신중..."
clnt_sock.sendto("Nice to meet you!!", (HOST, SERVER_PORT))
print "메시지 송신 완료"

print "메시지 수신 대기중..."
msg, addr = clnt_sock.recvfrom(1024)
print "메시지 수신 완료"
print msg, addr

